package com.etogc.groupchat.mine;

import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.Switch;

import com.etogc.groupchat.R;
import com.etogc.groupchat.base.BaseActivity;
import com.etogc.thirdsdk.rong.RongUtil;
import com.etogc.groupchat.common.CommonSp;
import com.etogc.util.YcToastHelper;

/**
 * 设置
 *
 * @author 绯若虚无
 * @version 2018年4月5日 星期四
 */
public class SettingActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        setTitle("设置");
        showBack();
        Switch swNotice = findViewById(R.id.swNotice);
        swNotice.setChecked(!CommonSp.canRecvMessage());
        swNotice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                CommonSp.setCanRecvMessge(!b);
                if (b) {
                    YcToastHelper.getInstance()._toast("启用勿扰模式");
                    RongUtil.switchNotice(SettingActivity.this, false);
                } else {
                    YcToastHelper.getInstance()._toast("关闭勿扰模式");
                    RongUtil.switchNotice(SettingActivity.this, true);
                }
            }
        });
    }
}
